<?php


namespace app\admin\controller\api;


use think\App;
use think\facade\Db;

class Goods extends Base
{
    public function __construct(App $app)
    {
        parent::__construct($app);
    }

    /*
     * 查询物品
     * */
    public function index(){
        $get = $this->request->get();
        if(isset($get['name']) && !empty($get['name'])){
            $map[] = ['title','like',"%{$get['name']}%"];
            $list = Db::name('wow_goods')->where($map)->page(1,10)->select();
        }else{
            $list = Db::name('wow_goods')->page(1,10)->select();
        }
        return json([
            'code' => 100,
            'data' => $list
        ]);
    }

    /*
     * 物品详情
     * */
    public function desc(){
        $gid = $this->request->get('gid');
        $list = Db::name('wow_goods_desc')->where('goods_id',$gid)->find();
        return json([
            'code' => 100,
            'data' => $list
        ]);
    }
}